home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / M2Crypto / m2xmlrpclib.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  2KB  |  55 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import base64
  5. import string
  6. import sys
  7. from xmlrpclib import *
  8. import M2Crypto
  9. import SSL
  10. import httpslib
  11. import m2urllib
  12. __version__ = M2Crypto.version
  13.  
  14. class SSL_Transport(Transport):
  15.     user_agent = 'M2Crypto_XMLRPC/%s - %s' % (__version__, Transport.user_agent)
  16.     
  17.     def __init__(self, ssl_context = None, *args, **kw):
  18.         if getattr(Transport, '__init__', None) is not None:
  19.             Transport.__init__(self, *args, **kw)
  20.         
  21.         if ssl_context is None:
  22.             self.ssl_ctx = SSL.Context('sslv23')
  23.         else:
  24.             self.ssl_ctx = ssl_context
  25.  
  26.     
  27.     def request(self, host, handler, request_body, verbose = 0):
  28.         (user_passwd, host_port) = m2urllib.splituser(host)
  29.         (_host, _port) = m2urllib.splitport(host_port)
  30.         h = httpslib.HTTPS(_host, int(_port), ssl_context = self.ssl_ctx)
  31.         if verbose:
  32.             h.set_debuglevel(1)
  33.         
  34.         h.putrequest('POST', handler)
  35.         h.putheader('Host', _host)
  36.         h.putheader('User-Agent', self.user_agent)
  37.         h.putheader('Content-Type', 'text/xml')
  38.         h.putheader('Content-Length', str(len(request_body)))
  39.         if user_passwd is not None:
  40.             auth = string.strip(base64.encodestring(user_passwd))
  41.             h.putheader('Authorization', 'Basic %s' % auth)
  42.         
  43.         h.endheaders()
  44.         if request_body:
  45.             h.send(request_body)
  46.         
  47.         (errcode, errmsg, headers) = h.getreply()
  48.         if errcode != 200:
  49.             raise ProtocolError(host + handler, errcode, errmsg, headers)
  50.         
  51.         self.verbose = verbose
  52.         return self.parse_response(h.getfile())
  53.  
  54.  
  55.